#include "../../include/logger.hpp"


using namespace xzt::log;

int main()
{
    // Level::value limit_level = Level::value::INFO;
    // Formatter::ptr formatter = std::make_shared<Formatter>();
    // std::vector<LogSink::ptr> sinks;
    // sinks.emplace_back(SinkFactory::create<StdoutSink>());
    // sinks.emplace_back(std::make_shared<FileSink>("test.log"));
    // sinks.emplace_back(std::make_shared<RollingBySizeFileSink>("./logs/log-", 1024 * 1024));

    // Logger::ptr logger = std::make_shared<SyncLogger>("my-logger", limit_level, formatter, sinks);

    // 利用建造者模式创建日志对象
    std::unique_ptr<LoggerBulider> builder = std::make_unique<LocalLoggerBulider>();
    // loggerType 若不进行设置，则默认使用 SyncLogger
    builder->bulidLoggerName("local-logger");
    builder->bulidLimitLevel(Level::value::DEBUG);
    // formatter 若不进行设置，则默认使用 DefaultPatternFormatter
    builder->bulidSink<StdoutSink>();
    builder->bulidSink<FileSink>("./logs/test.log");
    Logger::ptr logger = builder->bulid();  // 构建日志对象

    for(int i = 0; i < 100000; ++i)
    {
        int idx = i;
        logger->debug(__FILE__, __LINE__, "Debug... - {%d}", idx++);
        logger->info(__FILE__, __LINE__, "Info... - {%d}", idx++);
        logger->warn(__FILE__, __LINE__, "Warn... - {%d}", idx++);
        logger->error(__FILE__, __LINE__, "Error... - {%d}", idx++);
        logger->fatal(__FILE__, __LINE__, "Fatal... - {%d}", idx++);
    }
        
    return 0;
}

